Optimal. Leaf size=198 \[ b^3 (A b+4 a B) x+\frac {a \left (4 a^2 A b+8 A b^3+a^3 B+12 a b^2 B\right ) \tanh ^{-1}(\sin (c+d x))}{2 d}-\frac {b^2 \left (8 a A b+3 a^2 B-6 b^2 B\right ) \sin (c+d x)}{6 d}+\frac {a^2 \left (2 a^2 A+9 A b^2+9 a b B\right ) \tan (c+d x)}{3 d}+\frac {a (2 A b+a B) (a+b \cos (c+d x))^2 \sec (c+d x) \tan (c+d x)}{2 d}+\frac {a A (a+b \cos (c+d x))^3 \sec ^2(c+d x) \tan (c+d x)}{3 d} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.38, antiderivative size = 198, normalized size of antiderivative = 1.00, number of steps
used = 6, number of rules used = 6, integrand size = 31, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.194, Rules used = {3068, 3126,
3110, 3102, 2814, 3855} \begin {gather*} -\frac {b^2 \left (3 a^2 B+8 a A b-6 b^2 B\right ) \sin (c+d x)}{6 d}+\frac {a^2 \left (2 a^2 A+9 a b B+9 A b^2\right ) \tan (c+d x)}{3 d}+\frac {a \left (a^3 B+4 a^2 A b+12 a b^2 B+8 A b^3\right ) \tanh ^{-1}(\sin (c+d x))}{2 d}+b^3 x (4 a B+A b)+\frac {a (a B+2 A b) \tan (c+d x) \sec (c+d x) (a+b \cos (c+d x))^2}{2 d}+\frac {a A \tan (c+d x) \sec ^2(c+d x) (a+b \cos (c+d x))^3}{3 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 2814
Rule 3068
Rule 3102
Rule 3110
Rule 3126
Rule 3855
Rubi steps
\begin {align*} \int (a+b \cos (c+d x))^4 (A+B \cos (c+d x)) \sec ^4(c+d x) \, dx &=\frac {a A (a+b \cos (c+d x))^3 \sec ^2(c+d x) \tan (c+d x)}{3 d}+\frac {1}{3} \int (a+b \cos (c+d x))^2 \left (3 a (2 A b+a B)+\left (2 a^2 A+3 A b^2+6 a b B\right ) \cos (c+d x)-b (a A-3 b B) \cos ^2(c+d x)\right ) \sec ^3(c+d x) \, dx\\ &=\frac {a (2 A b+a B) (a+b \cos (c+d x))^2 \sec (c+d x) \tan (c+d x)}{2 d}+\frac {a A (a+b \cos (c+d x))^3 \sec ^2(c+d x) \tan (c+d x)}{3 d}+\frac {1}{6} \int (a+b \cos (c+d x)) \left (2 a \left (2 a^2 A+9 A b^2+9 a b B\right )+\left (8 a^2 A b+6 A b^3+3 a^3 B+18 a b^2 B\right ) \cos (c+d x)-b \left (8 a A b+3 a^2 B-6 b^2 B\right ) \cos ^2(c+d x)\right ) \sec ^2(c+d x) \, dx\\ &=\frac {a^2 \left (2 a^2 A+9 A b^2+9 a b B\right ) \tan (c+d x)}{3 d}+\frac {a (2 A b+a B) (a+b \cos (c+d x))^2 \sec (c+d x) \tan (c+d x)}{2 d}+\frac {a A (a+b \cos (c+d x))^3 \sec ^2(c+d x) \tan (c+d x)}{3 d}-\frac {1}{6} \int \left (-3 a \left (4 a^2 A b+8 A b^3+a^3 B+12 a b^2 B\right )-6 b^3 (A b+4 a B) \cos (c+d x)+b^2 \left (8 a A b+3 a^2 B-6 b^2 B\right ) \cos ^2(c+d x)\right ) \sec (c+d x) \, dx\\ &=-\frac {b^2 \left (8 a A b+3 a^2 B-6 b^2 B\right ) \sin (c+d x)}{6 d}+\frac {a^2 \left (2 a^2 A+9 A b^2+9 a b B\right ) \tan (c+d x)}{3 d}+\frac {a (2 A b+a B) (a+b \cos (c+d x))^2 \sec (c+d x) \tan (c+d x)}{2 d}+\frac {a A (a+b \cos (c+d x))^3 \sec ^2(c+d x) \tan (c+d x)}{3 d}-\frac {1}{6} \int \left (-3 a \left (4 a^2 A b+8 A b^3+a^3 B+12 a b^2 B\right )-6 b^3 (A b+4 a B) \cos (c+d x)\right ) \sec (c+d x) \, dx\\ &=b^3 (A b+4 a B) x-\frac {b^2 \left (8 a A b+3 a^2 B-6 b^2 B\right ) \sin (c+d x)}{6 d}+\frac {a^2 \left (2 a^2 A+9 A b^2+9 a b B\right ) \tan (c+d x)}{3 d}+\frac {a (2 A b+a B) (a+b \cos (c+d x))^2 \sec (c+d x) \tan (c+d x)}{2 d}+\frac {a A (a+b \cos (c+d x))^3 \sec ^2(c+d x) \tan (c+d x)}{3 d}+\frac {1}{2} \left (a \left (4 a^2 A b+8 A b^3+a^3 B+12 a b^2 B\right )\right ) \int \sec (c+d x) \, dx\\ &=b^3 (A b+4 a B) x+\frac {a \left (4 a^2 A b+8 A b^3+a^3 B+12 a b^2 B\right ) \tanh ^{-1}(\sin (c+d x))}{2 d}-\frac {b^2 \left (8 a A b+3 a^2 B-6 b^2 B\right ) \sin (c+d x)}{6 d}+\frac {a^2 \left (2 a^2 A+9 A b^2+9 a b B\right ) \tan (c+d x)}{3 d}+\frac {a (2 A b+a B) (a+b \cos (c+d x))^2 \sec (c+d x) \tan (c+d x)}{2 d}+\frac {a A (a+b \cos (c+d x))^3 \sec ^2(c+d x) \tan (c+d x)}{3 d}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Leaf count is larger than twice the leaf count of optimal. \(415\) vs. \(2(198)=396\).
time = 3.77, size = 415, normalized size = 2.10 \begin {gather*} \frac {12 b^3 (A b+4 a B) (c+d x)-6 a \left (4 a^2 A b+8 A b^3+a^3 B+12 a b^2 B\right ) \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+6 a \left (4 a^2 A b+8 A b^3+a^3 B+12 a b^2 B\right ) \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )+\frac {a^3 (12 A b+a (A+3 B))}{\left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )^2}+\frac {2 a^4 A \sin \left (\frac {1}{2} (c+d x)\right )}{\left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )^3}+\frac {8 a^2 \left (a^2 A+9 A b^2+6 a b B\right ) \sin \left (\frac {1}{2} (c+d x)\right )}{\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )}+\frac {2 a^4 A \sin \left (\frac {1}{2} (c+d x)\right )}{\left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )^3}-\frac {a^3 (12 A b+a (A+3 B))}{\left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )^2}+\frac {8 a^2 \left (a^2 A+9 A b^2+6 a b B\right ) \sin \left (\frac {1}{2} (c+d x)\right )}{\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )}+12 b^4 B \sin (c+d x)}{12 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.33, size = 209, normalized size = 1.06 Too large to display
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.27, size = 245, normalized size = 1.24 \begin {gather*} \frac {4 \, {\left (\tan \left (d x + c\right )^{3} + 3 \, \tan \left (d x + c\right )\right )} A a^{4} + 48 \, {\left (d x + c\right )} B a b^{3} + 12 \, {\left (d x + c\right )} A b^{4} - 3 \, B a^{4} {\left (\frac {2 \, \sin \left (d x + c\right )}{\sin \left (d x + c\right )^{2} - 1} - \log \left (\sin \left (d x + c\right ) + 1\right ) + \log \left (\sin \left (d x + c\right ) - 1\right )\right )} - 12 \, A a^{3} b {\left (\frac {2 \, \sin \left (d x + c\right )}{\sin \left (d x + c\right )^{2} - 1} - \log \left (\sin \left (d x + c\right ) + 1\right ) + \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + 36 \, B a^{2} b^{2} {\left (\log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + 24 \, A a b^{3} {\left (\log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + 12 \, B b^{4} \sin \left (d x + c\right ) + 48 \, B a^{3} b \tan \left (d x + c\right ) + 72 \, A a^{2} b^{2} \tan \left (d x + c\right )}{12 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.39, size = 219, normalized size = 1.11 \begin {gather*} \frac {12 \, {\left (4 \, B a b^{3} + A b^{4}\right )} d x \cos \left (d x + c\right )^{3} + 3 \, {\left (B a^{4} + 4 \, A a^{3} b + 12 \, B a^{2} b^{2} + 8 \, A a b^{3}\right )} \cos \left (d x + c\right )^{3} \log \left (\sin \left (d x + c\right ) + 1\right ) - 3 \, {\left (B a^{4} + 4 \, A a^{3} b + 12 \, B a^{2} b^{2} + 8 \, A a b^{3}\right )} \cos \left (d x + c\right )^{3} \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, {\left (6 \, B b^{4} \cos \left (d x + c\right )^{3} + 2 \, A a^{4} + 4 \, {\left (A a^{4} + 6 \, B a^{3} b + 9 \, A a^{2} b^{2}\right )} \cos \left (d x + c\right )^{2} + 3 \, {\left (B a^{4} + 4 \, A a^{3} b\right )} \cos \left (d x + c\right )\right )} \sin \left (d x + c\right )}{12 \, d \cos \left (d x + c\right )^{3}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: SystemError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 387 vs.
\(2 (188) = 376\).
time = 0.50, size = 387, normalized size = 1.95 \begin {gather*} \frac {\frac {12 \, B b^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 1} + 6 \, {\left (4 \, B a b^{3} + A b^{4}\right )} {\left (d x + c\right )} + 3 \, {\left (B a^{4} + 4 \, A a^{3} b + 12 \, B a^{2} b^{2} + 8 \, A a b^{3}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right ) - 3 \, {\left (B a^{4} + 4 \, A a^{3} b + 12 \, B a^{2} b^{2} + 8 \, A a b^{3}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right ) - \frac {2 \, {\left (6 \, A a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 3 \, B a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 12 \, A a^{3} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 24 \, B a^{3} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 36 \, A a^{2} b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 4 \, A a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 48 \, B a^{3} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 72 \, A a^{2} b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 6 \, A a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 3 \, B a^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 12 \, A a^{3} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 24 \, B a^{3} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 36 \, A a^{2} b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1\right )}^{3}}}{6 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 2.83, size = 636, normalized size = 3.21 \begin {gather*} \frac {\frac {A\,a^4\,\sin \left (3\,c+3\,d\,x\right )}{6}+\frac {B\,a^4\,\sin \left (2\,c+2\,d\,x\right )}{4}+\frac {B\,b^4\,\sin \left (2\,c+2\,d\,x\right )}{4}+\frac {B\,b^4\,\sin \left (4\,c+4\,d\,x\right )}{8}+\frac {A\,a^4\,\sin \left (c+d\,x\right )}{2}+B\,a^3\,b\,\sin \left (c+d\,x\right )+\frac {3\,A\,b^4\,\cos \left (c+d\,x\right )\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{2}+A\,a^3\,b\,\sin \left (2\,c+2\,d\,x\right )+\frac {3\,A\,a^2\,b^2\,\sin \left (c+d\,x\right )}{2}+B\,a^3\,b\,\sin \left (3\,c+3\,d\,x\right )+\frac {A\,b^4\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\cos \left (3\,c+3\,d\,x\right )}{2}+\frac {3\,A\,a^2\,b^2\,\sin \left (3\,c+3\,d\,x\right )}{2}+2\,B\,a\,b^3\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\cos \left (3\,c+3\,d\,x\right )+6\,B\,a\,b^3\,\cos \left (c+d\,x\right )\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )-\frac {B\,a^4\,\cos \left (c+d\,x\right )\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,1{}\mathrm {i}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,3{}\mathrm {i}}{4}-\frac {B\,a^4\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,1{}\mathrm {i}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\cos \left (3\,c+3\,d\,x\right )\,1{}\mathrm {i}}{4}-A\,a\,b^3\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,1{}\mathrm {i}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\cos \left (3\,c+3\,d\,x\right )\,2{}\mathrm {i}-A\,a^3\,b\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,1{}\mathrm {i}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\cos \left (3\,c+3\,d\,x\right )\,1{}\mathrm {i}-B\,a^2\,b^2\,\cos \left (c+d\,x\right )\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,1{}\mathrm {i}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,9{}\mathrm {i}-B\,a^2\,b^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,1{}\mathrm {i}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\cos \left (3\,c+3\,d\,x\right )\,3{}\mathrm {i}-A\,a\,b^3\,\cos \left (c+d\,x\right )\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,1{}\mathrm {i}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,6{}\mathrm {i}-A\,a^3\,b\,\cos \left (c+d\,x\right )\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,1{}\mathrm {i}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,3{}\mathrm {i}}{d\,\left (\frac {3\,\cos \left (c+d\,x\right )}{4}+\frac {\cos \left (3\,c+3\,d\,x\right )}{4}\right )} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________